use proc_macro2::TokenStream;
use quote::quote;
use syn::Item;
use syn::Result;

pub fn impl_state_expand(item: Item) -> Result<TokenStream> {
    let Item::Struct(item) = item else {
        return Err(moss::error::Error::custom("not supported item").into());
    };
    let ident = &item.ident;
    let expanded = quote! {
        #[derive(Clone, axum::extract::FromRef)]
        #item

        carpet::server::define_handler_straw!(#ident);

        pub type __AppState = #ident;
        pub type __MethodHandlerStrawImpl = MethodHandlerStrawImpl;
    };
    Ok(expanded)
}
